package cn.hicard.risk.service.bd.impl;

import java.util.HashMap;
import java.util.List;

import org.springframework.stereotype.Service;

import cn.hicard.core.Where;
import cn.hicard.risk.dao.bd.BusinessDao;
import cn.hicard.risk.entity.BdBusiness;
import cn.hicard.risk.service.bd.BusinessService;
import cn.hicard.util.AppConfig;
import cn.hicard.util.ControlMark;

@Service
public class BusinessServiceImpl implements BusinessService{
	
	private BusinessDao businessDao;
	
	public void setBusinessDao(BusinessDao businessDao) {
		this.businessDao = businessDao;
	}
	
	public List<BdBusiness> findList(Where where) throws Exception{
		return businessDao.findList(where);
	}
	
	public void save(BdBusiness bdBusiness) throws Exception{
		businessDao.save(bdBusiness);
	}
	
	public void update(BdBusiness bdBusiness) throws Exception{
		businessDao.update(bdBusiness);
	}
	
	/**
	 * 查询业务配置详细信息靠商户ID，商户终端ID，收单ID，收单终端ID
	 * @throws Exception 
	 */
	public BdBusiness getBusinessDetailByAllId(String hmId,String htId,String omId,String otId){
		
		Where where=new Where(BdBusiness.class);
		where.addEqual("hmId",hmId);
		where.addEqual("htId", htId);
		where.addEqual("omId", omId);
		where.addEqual("otId",otId);
		BdBusiness bdBusiness = new BdBusiness();
		try {
			List<BdBusiness> list = businessDao.findList(where);
		
			if(list!=null&&list.size()>0){
				 bdBusiness=list.get(0);
				 bdBusiness.setControlStatus(ControlMark.getValue(bdBusiness.getControlStatus()));			 
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return bdBusiness;
	}
	
	public List<String> findPeriodList(BdBusiness bus) throws Exception {
		return businessDao.findPeriodList(bus);
		
	}
}
